package com.study.a06Test1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class Sever {
    public static void main(String[] args) throws IOException {

        //创建socket对象
        ServerSocket serverSocket= new ServerSocket(9000);

        //监听客户端连接
        Socket socket=serverSocket.accept();
        while (true) {
            InputStreamReader br=new InputStreamReader(socket.getInputStream());
            int b;
            while((b=br.read())!=-1){
                System.out.print((char)b);
            }
            if(socket.equals("exit")){
                break;
            }
        }

        //关闭socket
        socket.close();
        serverSocket.close();
    }
}
